fldmeta_prop.func.EndEvent = {};

//on color change of EndEvent
fldmeta_prop.func.EndEvent.onDisplayStyle = function(elemid, rId, nv) {
	if (rId=="displayStyle_GradientColor0") {
		var grd = Snap("svg").select("#Gradient_"+elemid);
		grd && grd.remove();
		var c0 = nv;
		var c1 = fl.curflow.bpmnConfig[elemid]["displayStyle_GradientColor1"]|| flstyle.elem.gradients.EndEvent.b;
		var c2 = fl.curflow.bpmnConfig[elemid]["displayStyle_GradientColor2"]||flstyle.elem.gradients.EndEvent.c;
		//console.log(nv);
		grd = Snap("svg").paper.gradient("L(0, 0, 30, 30)"+c0+"-"+c1+":25-"+c2);
		grd.attr("id", "Gradient_"+elemid);
		Snap("g[data-element-id='"+elemid+"'] g.djs-visual circle").attr({"fill" : "url(#Gradient_"+elemid+")"});
	} else if (rId=="displayStyle_GradientColor1") {
		var grd = Snap("svg").select("#Gradient_"+elemid);
		grd && grd.remove();
		var c0 = fl.curflow.bpmnConfig[elemid]["displayStyle_GradientColor0"]||flstyle.elem.gradients.EndEvent.a;
		var c1 = nv;
		var c2 = fl.curflow.bpmnConfig[elemid]["displayStyle_GradientColor2"]||flstyle.elem.gradients.EndEvent.c;
		grd = Snap("svg").paper.gradient("L(0, 0, 30, 30)"+c0+"-"+c1+":25-"+c2);
		grd.attr("id", "Gradient_"+elemid);
		Snap("g[data-element-id='"+elemid+"'] g.djs-visual circle").attr({"fill" : "url(#Gradient_"+elemid+")"});
	} else if (rId=="displayStyle_GradientColor2") {
		var grd = Snap("svg").select("#Gradient_"+elemid);
		grd && grd.remove();
		var c0 = fl.curflow.bpmnConfig[elemid]["displayStyle_GradientColor0"]||flstyle.elem.gradients.EndEvent.a;
		var c1 = fl.curflow.bpmnConfig[elemid]["displayStyle_GradientColor1"]||flstyle.elem.gradients.EndEvent.b;
		var c2 = nv;
		grd = Snap("svg").paper.gradient("L(0, 0, 30, 30)"+c0+"-"+c1+":25-"+c2);
		grd.attr("id", "Gradient_"+elemid);
		Snap("g[data-element-id='"+elemid+"'] g.djs-visual circle").attr({"fill" : "url(#Gradient_"+elemid+")"});
	} else if (rId=="displayStyle_BorderEffect") {
		if (nv=='none' || !nv) {
			Snap("g[data-element-id='"+elemid+"'] g.djs-visual circle").attr("filter", null);
		} else {
			Snap("g[data-element-id='"+elemid+"'] g.djs-visual circle").attr("filter","url(#"+nv+")");
		}
	} else if (rId=="displayStyle_BorderStrokeWidth") {
		var bv = nv||flstyle.elem.attrs.end.strokeWidth;
		Snap("g[data-element-id='"+elemid+"'] g.djs-visual circle").attr({"strokeWidth" : parseInt(bv)});
	} else if (rId=="displayStyle_BorderColor") {
		Snap("g[data-element-id='"+elemid+"'] g.djs-visual circle").attr({"stroke" : nv});
	} else if (rId=="displayStyle_fontColor") {
		var text = Snap("g[data-element-id='"+elemid+"_label'] g.djs-visual text");
		text && text.attr({"fill" : nv || "#000000"});
	}
};

//properties settings for EndEvent
fldmeta_prop.control.EndEvent = {
		"includes-properties" : {
			"common" : fldmeta_prop.common.all.properties,
			"eventcommon" : fldmeta_prop.common.event.properties
		},
		"properties" : {
			/*"forceterminate" : {
				"name" : fmd_i18n_prop_forceterminate,
		    	"img" : "duration.png",
		    	"tooltip" : fmd_i18n_tooltip_forceterminate,
		    	"cellType" : "ch",
		    	"value" : {"default":0}
			},*/
		},
		"styles" : {
			"displayStyle" : {
				"name" : fmd_i18n_prop_tip_customstyle,
				"img" : "css.png",
		    	"cellType" : {
		    		"type" : "coro",
		    		"options" : fmd_i18n_prop_displayStyle_vals
		    	},
		    	"value" : {"default":"theme"},
		    	"conditional-sub" : {
		    		"custom" : {
		    			"displayStyle_GradientColor0" : {
		        			"name" : fmd_i18n_prop_color0,
		    		    	"cellType" : "cp",
		    		    	"img" : "color.png",
		    		    	"value" : function() {return flstyle.elem.gradients.EndEvent.a}
		        		},
		        		"displayStyle_GradientColor1" : {
		        			"name" : fmd_i18n_prop_color1,
		    		    	"cellType" : "cp",
		    		    	"img" : "color.png",
		    		    	"value" : function() {return flstyle.elem.gradients.EndEvent.b}
		        		},
		        		"displayStyle_GradientColor2" : {
		        			"name" : fmd_i18n_prop_color2,
		    		    	"cellType" : "cp",
		    		    	"img" : "color.png",
		    		    	"value" : function() {return flstyle.elem.gradients.EndEvent.c}
		        		},
		        		"displayStyle_fontColor" : function() {
		    				var obj1 = MyUtilJs.copyObj(fldmeta_prop.common.predefined["displayStyle_fontColor"]);
		    				obj1.value["default"] = flstyle.elem.defaultFontColor;
		    				return obj1;
		    			},
		        		"displayStyle_BorderStrokeWidth" : function() {
		    				var obj1 = MyUtilJs.copyObj(fldmeta_prop.common.predefined["displayStyle_BorderStrokeWidth"]);
		    				obj1.value["default"] = flstyle.elem.attrs.end.strokeWidth;
		    				return obj1;
		    			},
		        		"displayStyle_BorderColor" : function() {
		    				var obj1 = MyUtilJs.copyObj(fldmeta_prop.common.predefined["displayStyle_BorderColor"]);
		    				obj1.value["default"] = flstyle.elem.attrs.end.stroke;
		    				return obj1;
		    			},
		        		"displayStyle_BorderEffect" : fldmeta_prop.common.predefined["displayStyle_BorderEffect"]
		    		}
		    	}
			}
		},
		"onApply" : function() {
		},
		"propDhxGridEvents" : {
			"onCellChanged" : function(rId,cId,nv) {
				fldmeta_prop.func.onCellChanged_common(rId,cId,nv,
						JSONSelect.match("."+rId, fldmeta_prop.control.EndEvent));
				fldmeta_prop.func.onCellChanged_stylecommon(rId,cId,nv);
			}
		}
	};



